package com.mingqijia.gassafety.shared.constant.runningReport;

public enum ReportAlarmTypeEnum {

    ALARM(0, "报警", "4874CB"),
    BROKEN(1, "故障", "#30C0B4"),
    OFFLINE(2, "离线", "#cccccc");

    private Integer code;
    private String name;
    private String color;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    ReportAlarmTypeEnum(Integer code, String name, String color) {
        this.code = code;
        this.name = name;
        this.color = color;
    }

    private static final ReportAlarmTypeEnum[] VALUES = ReportAlarmTypeEnum.values();

    public static ReportAlarmTypeEnum matcher(int value) {
        for (ReportAlarmTypeEnum ele : VALUES) {
            if (ele.code == value) {
                return ele;
            }
        }
        return null;
    }

    public static String getNameByCode(Integer code) {
        String nameValue = "";
        for (ReportAlarmTypeEnum mode : ReportAlarmTypeEnum.values()) {
            if (mode.getCode().equals(code)) {
                nameValue = mode.getName();
                break;
            }
        }
        return nameValue;
    }

    public static String getColorByCode(Integer code) {
        String nameValue = "";
        for (ReportAlarmTypeEnum mode : ReportAlarmTypeEnum.values()) {
            if (mode.getCode().equals(code)) {
                nameValue = mode.getColor();
                break;
            }
        }
        return nameValue;
    }

    public static String getColorByName(String name) {
        String nameValue = "";
        for (ReportAlarmTypeEnum mode : ReportAlarmTypeEnum.values()) {
            if (mode.getName().equals(name)) {
                nameValue = mode.getColor();
                break;
            }
        }
        return nameValue;
    }

}
